package com.vvlive.caibao.smartcity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.vvlive.caibao.smartcity.bean.MeetingRoom;

import java.util.List;

import smartcity.vvlive.caibao.com.smartc.R;

/**
 * Created by zhj on 2015/9/7.
 */
public class AllMeetingRoomsAdapter extends BaseAdapter {

    private LayoutInflater mInflater;
    private List<MeetingRoom> rooms;

    public AllMeetingRoomsAdapter(Context context, List<MeetingRoom> rooms) {
        this.rooms = rooms;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return rooms.size();
    }

    @Override
    public Object getItem(int position) {
        return rooms.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_all_meeting_rooms_list, null);
            holder.name = (TextView) convertView.findViewById(R.id.meeting_room_name);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        MeetingRoom room = (MeetingRoom) getItem(position);
        holder.name.setText(room.getRoom());
        return convertView;
    }

    static final class ViewHolder{
        TextView name;
    }
}
